﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AdministradorForm
{
    public partial class SeleccionarPedidoForm : PlantillaForm
    {
        private int id_pedido = 0;
        public int Id_pedido
        {
            get { return id_pedido; }
        }

        public SeleccionarPedidoForm()
        {
            InitializeComponent();
        }

        private void SeleccionarPedidoForm_Load(object sender, EventArgs e)
        {
            ServiceReferenceAdmin.Service1SoapClient srv = new AdministradorForm.ServiceReferenceAdmin.Service1SoapClient();
            dataGridView1.DataSource = srv.ListarPedidosPendientes();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            id_pedido = 0;
            //this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (id_pedido == 0)
                MessageBox.Show("Debe seleccionar un pedido", "Error en selección de pedido", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            else
            {
                SeleccionarTecnicoForm form = new SeleccionarTecnicoForm(this);
                form.ShowDialog();
                ServiceReferenceAdmin.Service1SoapClient srv = new AdministradorForm.ServiceReferenceAdmin.Service1SoapClient();
                dataGridView1.DataSource = srv.ListarPedidosPendientes();
                dataGridView1.Refresh();
            }
        }

        private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            id_pedido = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
        }
    }
}
